package java8Test.function.lambda;

import org.junit.Test;

import java.util.HashMap;
import java.util.Map;

public class MapTest {

    @Test
    public void mergeTest(){
        Map<Integer, Integer> reward1 = new HashMap<>();
        Map<Integer, Integer> reward2 = new HashMap<>();

        reward1.put(1, 2);
        reward2.put(2, 4);

        reward2.forEach((k, v) -> reward1.merge(k, v, Integer::sum));
        System.out.println(reward2);
        System.out.println(reward1);
    }
}
